package 传智播客_黑马.java高级.网络编程;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class bb {
    public bb() {
        try {
        DatagramSocket datagramSocket = new DatagramSocket(6060);


            byte[] bytes = new byte[1024];
            int len;
            DatagramPacket datagramPacket = new DatagramPacket(bytes,0,bytes.length);

        datagramSocket.receive(datagramPacket);

            System.out.println(new String(datagramPacket.getData(),0,datagramPacket.getLength()));

    } catch (SocketException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    }

    public static void main(String[] args) {
        new bb();
    }
}
